<?php include template('header','common');?>
<link rel="stylesheet" type="text/css" href="{__ROOT__}template/default/statics/css/shengfenyanzhen.css?v={HD_VERSION}">
<script type="text/javascript" src="{__ROOT__}statics/js/haidao.validate.js?v={HD_VERSION}"></script>
<div class="container">
	<div class="content1">
		<div class="item1">
			<div class="top">
				<img src="{$schoolData['logo']}" alt="">
				<div class="top-content">
					<span>{$schoolData['name']}午托班</span>
				</div>
				<span class="top-price"></span>
			</div>
			{if $schoolData['deps']}
			<div class="bottom">
				<span class="bottom-title">
					已加入的家长
					<i>({$schoolData['count']}/{$classNumber})</i>
				</span>
				<div class="bottom-img">
					<?php foreach($schoolData['deps'] as $k => $v){?>
					<div>
						<img src="{$v['avatar']}" alt="">
					</div>
					<?php }?>
				</div>
			</div>
			{/if}
			{if $schoolData['class_id'] == 0}
            <img class="sign" src="{__ROOT__}template/default/statics/img/faqi.png" alt="">
            {else}
            <img class="sign" src="{__ROOT__}template/default/statics/img/kaiban.png" alt="">
            {/if}
		</div>
	</div>
	
	<form class="padding-small" method="post" action='{url("validation",array("formhash"=>FORMHASH))}' name="checkmobile">
	<div class="content">
		<div class="list">
			<div class="item">
				<img src="{SKIN_PATH}statics/img/xue-sheng-xing-ming-.png" alt="">
				<input type="text" name="truename" value="{$students['truename']}" placeholder="请填写孩子真实姓名">
			</div>
			<div class="item">
				<img src="{SKIN_PATH}statics/img/xue-sheng-xing-ming-.png" alt="">
				<select name="sex">
					<option value="0">请选择性别</option>	
					<option value="1" {if $students['sex'] == 1}selected="selected"{/if}>男</option>	
					<option value="2" {if $students['sex'] == 2}selected="selected"{/if}>女</option>
				</select>
			</div>
			<div class="item" style="display:none;">
				<img src="{SKIN_PATH}statics/img/diqu-.png" alt="">
				<select name="area">
					<option value="">请选择所在区域</option>		
					<?php foreach($areas as $k => $v){?>
						{if $schoolData['area'] == $v['area']}
						<option value="{$v['area']}" selected="selected">{$v['area']}</option>
						{else}
						<option value="{$v['area']}">{$v['area']}</option>
						{/if}
					<?php }?>		
				</select>
			</div>
			<div class="item">
				<img src="{SKIN_PATH}statics/img/xue-xiao-1.png" alt="">
				<select name="school_id">
					<option value="">请选择学校</option>		
					<?php foreach($schools as $k => $v){?>
						<option value="{$v['id']}">{$v['name']}</option>
					<?php }?>		
				</select>
			</div>
			<div class="item">
				<img src="{SKIN_PATH}statics/img/xue-xiao-1.png" alt="">
				<input type="text" name="class_name" value="{$students['class_name']}" placeholder="请填班级，格式：203表示二年级3班">
			</div>
			<input type="hidden" name="sid" value="{$sid}" />
			<input type="hidden" name="iid" value="{$schoolData['iid']}" />
			<input type="hidden" name="class_id" value="{$schoolData['class_id']}" />
		</div>
		<div class="btn">
			<div class="tishi" >
				<img src="{SKIN_PATH}statics/img/ti-shi-.png" alt="">
                {if $schoolData['class_id'] == 0}
                该校暂未开通安昕午托，您可以发起午托。申请人数达到{$schoolData['number']}人即可开班，分享邀请能加速开班噢~系统和客服会及时通知您缴费哒~
                {else}
                恭喜您，本校午托班有学位。现在缴费，系统将为您锁定学位并从3天后开始计费，请孩子在该日期加入午托班。获取午托地址和联系老师请在完成缴费后进入“托班圈”。
                {/if}
			</div>
		</div>
		<div class="btn-view">
			{if $schoolData['class_id'] > 0}
			<button class="btn2 faqiBtn">加入</button>
			{else}
			<button class="btn2 faqiBtn">发起</button>
			{/if}
			<button class="btn1" type="button" onclick="_system._guide(true)">邀请有礼</button>
		</div>
	</div>
	</form>
</div>
<link type="text/css" rel="stylesheet" href="{__ROOT__}statics/js/upload/uploader.css?v={HD_VERSION}" />
<script type="text/javascript" src="{__ROOT__}statics/js/upload/uploader.js?v={HD_VERSION}"></script>
<script>
	{if $students}
	var school_id = {$students['school_id']};
	getSchool($("[name='area']").val());
	{else}
	var school_id = {$schoolData['id']};
	getSchool($("[name='area']").val());
	{/if}
	var resetmobile = $("form[name=checkmobile]").Validform({
		ajaxPost:true,
		beforeCheck:function(){
			if($("input[name=truename]").val() == ''){
				alerts('请填写孩子真实姓名');
				$("input[name=truename]").focus();
				return false;
			}
			if($("select[name=sex]").val() == 0){
				alerts('请选择性别');
				$("select[name=sex]").focus();
				return false;
			}
			if($("select[name=school_id]").val() == ''){
				alerts('请选择学校');
				$("select[name=school_id]").focus();
				return false;
			}
			if($("input[name=class_name]").val() == ''){
				alerts('请填班级，格式：203表示二年级3班');
				$("input[name=class_name]").focus();
				return false;
			}			
			var pattern = /^\d{1}[01]\d{1}$/; 
			if(pattern.test($("input[name=class_name]").val())  == false){
				alerts('班级格式错误，如：203表示二年级3班');
				$("input[name=class_name]").focus();
				return false;
			}
		},
		callback:function(ret){
			if(ret.status == 1){
				window.location.href=ret.referer;
			}else{
				alerts(ret.message);
			}
		}		
	});
	
	$("[name='area']").change(function(){
		getSchool($(this).val());
	});
	function getSchool(area){
		var ajaxurl="<?php echo url('school/index/getSchool')?>";
		var _html = '<option value="">请选择学校</option>';
		$.post(ajaxurl,{'area':area},function(data){
			var list = data.result;
			$.each(list, function(i, v) {
				if(school_id == v.id){
					_html += '<option value="'+v.id+'" selected="selected">'+v.name+'</option>';
				}else{
					_html += '<option value="'+v.id+'">'+v.name+'</option>';
				}
			});
			$("[name='school_id']").html(_html);
		},'json');
	}
</script>
<?php include template('footer','common');?>
